<template>
<div class="home-page">
  <el-container>
    <!-- 侧边栏 -->
    <el-aside width="200">
       <h1 class="logo"
    style="height:60px text-align:center">万峰智慧
    <!-- <img class="img" src="../../assets/img/1.gif"> -->
    </h1>
      <!-- :default-active="$route.path"  处理导航栏点击高亮 -->
    <el-menu :default-active="$route.path"  
     class="el-menu-vertical-demo" 
   :router="true"
     @open="handleOpen"
      @close="handleClose"  
      :collapse="isCollapse">
      <qf-sub-menu :sideMenu="menuList"></qf-sub-menu>
</el-menu>
    </el-aside>
  <el-container>
    <!-- 顶部栏 -->
    <el-header>
<el-row type="flex" class="row-bg" justify="space-around">
  <el-col :span="6">
    <div class="grid-content bg-purple">
      <i class="iconfont icon-shouqi" @click="isCollapse=!isCollapse"></i>
      图案
      </div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light">管理系统</div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple">
    <el-avatar :size="40" fit="fit" src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3741743995,3128714339&fm=26&gp=0.jpg"></el-avatar>
    <span>欢迎您:</span>
    <b class="nickname" @click="$router.push('/Mine')">{{userInfo.nickname}}</b>
    <span class="quit" @click="quit">退出</span>
    </div></el-col>
</el-row>
    </el-header>
    <!-- 主体区域 -->
    <el-main>
      <el-breadcrumb separator-class="el-icon-arrow-right">
  <el-breadcrumb-item :to="{ path: '/Welcome' }">首页</el-breadcrumb-item>
  <el-breadcrumb-item :to="{path:crumb.path}" 
  v-for="crumb in crumbs" :key="crumb.id">
  {{crumb.meta.name}}
  </el-breadcrumb-item>
</el-breadcrumb>
    <router-view></router-view>
    </el-main>
  </el-container>
</el-container>
</div>
</template>
<script>
// import {getLoginLog} from "@/api"
import {mapState} from "vuex"
  export default {//侧边栏
    computed: {
      ...mapState(["userInfo","menuList","crumbs"])
    },
    data() {
      return {
        isCollapse: false
      };
    },
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      },
      quit(){
        //退出登入
        //1.清楚token和userInfo
        //2.跳转到登入页
        localStorage.removeItem("ht-token")
        localStorage.removeItem("ht-userInfo")

        this.$router.push("/login")
        //重新渲染页面，解决换另一个用户进去，不要刷新自动重新渲染
        window.location.reload()
      }
    },
    mounted () {
      // getLoginLog()
      // .then(res=>{
      //   console.log(res);
      // })

    }

  }
</script>

<style scoped>

/* icon-shouqi */

.icon-shouqi{
  color: darkmagenta;
  font-size: 30px;
  cursor: pointer;
}
/* 侧边栏 */
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
  }
  .el-header, .el-footer {
   background-color:pink;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
  /* 顶部栏 */
  .el-row {
    margin-bottom: 20px;
  }
  .el-col {
    border-radius: 4px;
  }
  /* .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  } */
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding:0;
   /* background-color: pink; */
  }
  .el-aside {
    /* background-color: #D3DCE6; */
    color: #333;
    text-align: center;
    /* line-height: 200px; */
  }
  
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    line-height: 160px;
  }
  
  body > .el-container {
    margin-bottom: 40px;
  }
  
  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }
  
  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
  /* 头像 */
 .el-avatar{
   vertical-align: middle;
 }
 span{
   margin-left: 10px;
 }
 /* 退出 */
 .quit{
   cursor: pointer;
   color:green;
 }
 /* 后台系统 */
 .logo{
  height: 60px;
background-color: darksalmon;
font-size:20px;
line-height: 60px;
text-align: center;
 /* background-image:url("../../assets/img/1.gif"); */
    background-size:100%;
    background-repeat:no-repeat;
 }
 /* .img{
   width: 100%;
   height: 100%;
 } */
</style>